package com.atguigu.admin.controller;

import com.atguigu.admin.bean.City;
import com.atguigu.admin.mapper.CityDao;
import com.atguigu.admin.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author 杨林
 * @create 2023-09-01 9:14 星期五
 * description:
 */
@Controller
public class TestSqlController {
    
    @Autowired
    JdbcTemplate jdbcTemplate;
    
    @Autowired
    CityService cityService;
    
    @ResponseBody
    @GetMapping("/sql")
    public String queryFromDb(){
        Long aLong = jdbcTemplate.queryForObject("select count(*) from user_info", Long.class);
        return aLong.toString();
    }
    
    @ResponseBody
    @GetMapping("/city")
    public City getCity(@RequestParam("id") Integer id){
        City city = cityService.getCity(id);
        return city;
    }
    
}
